﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IPC.Communication.Core;
using IPC.Communication.Reflection;
using IPC.Communication.Serial;

namespace IPC.Communication.Profinet.FATEK
{
    public class FatekProgram : SerialDeviceBase
    {
        private byte station = 1;

        public byte Station
        {
            get
            {
                return station;
            }
            set
            {
                station = value;
            }
        }

        public FatekProgram()
        {
            base.ByteTransform = new RegularByteTransform();
            base.WordLength = 1;
        }

        [HslMqttApi("ReadByteArray", "")]
        public override OperateResult<byte[]> Read(string address, ushort length)
        {
            return FatekProgramHelper.Read(this, station, address, length);
        }

        [HslMqttApi("WriteByteArray", "")]
        public override OperateResult Write(string address, byte[] value)
        {
            return FatekProgramHelper.Write(this, station, address, value);
        }

        [HslMqttApi("ReadBoolArray", "")]
        public override OperateResult<bool[]> ReadBool(string address, ushort length)
        {
            return FatekProgramHelper.ReadBool(this, station, address, length);
        }

        [HslMqttApi("WriteBoolArray", "")]
        public override OperateResult Write(string address, bool[] value)
        {
            return FatekProgramHelper.Write(this, station, address, value);
        }

        public override string ToString()
        {
            return String.Format("FatekProgram[{0}:{1}]", base.PortName, base.BaudRate);
        }
    }
}
